import 'package:backend.auth/domain/entities/access_credentials.dart';
import 'package:equatable/equatable.dart';

const kAccessCredentialsAccessTokenDataKey = 'access_token';
const kAccessCredentialsRefreshTokenValueKey = 'refresh_token';

class AccessCredentialsDto extends Equatable {
  const AccessCredentialsDto._internal({
    required this.accessTokenData,
    required this.refreshTokenValue,
  });

  final String accessTokenData;
  final String refreshTokenValue;

  @override
  List<Object?> get props {
    return [
      accessTokenData,
      refreshTokenValue,
    ];
  }

  factory AccessCredentialsDto.fromEntity(AccessCredentials accessCredentials) {
    return AccessCredentialsDto._internal(
      accessTokenData: accessCredentials.accessToken.data,
      refreshTokenValue: accessCredentials.refreshToken.value,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      kAccessCredentialsAccessTokenDataKey: accessTokenData,
      kAccessCredentialsRefreshTokenValueKey: refreshTokenValue,
    };
  }
}
